﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace Model
{
    /// <summary>
    /// RESPONSABILITY: -data bucket
    ///                 -add, remove roles 
    ///                 -calculate the wage of the employee
    /// </summary>
    public class Employee : ICalculateWage
    {
        public string EmployeeName{get;set;}
        public string EmployeeCode{get;set;}
        public DateTime HireDate{get;set;}
        private List<Role> employeeRoles{get;set;}
        public List<User> users;

        IDGenerator idGenerator =IDGenerator.Instance;
        public double BaseWage{get;set;}
        public double Wage
        {
            get
            { 
                double wage=this.BaseWage;;
                foreach (Role role in this.employeeRoles)
                {
                    if (role.Bonus != null)
                    {
                        wage += role.Bonus.CalculateWage(this);            
                    }
                }

               return wage;
            }
           
        }
        public int EmployeeId{get;private set;}
        static private List<int> employeeIds{get;set;}

        private int EmployeeId_generator()
        {
            Type type=typeof(Employee);
            return idGenerator.RandomIDGenerator(type);
        }

        public  Employee(string employeeName, string employeeCode, DateTime hireDate, double baseWage)
        {   
            this.EmployeeName = employeeName;
            this.EmployeeCode = employeeCode;
            this.HireDate = hireDate;
            this.BaseWage = baseWage;
            employeeIds = new List<int>();
            employeeRoles = new List<Role>();
            EmployeeId = EmployeeId_generator();
            employeeIds.Add(EmployeeId);
        }

        public void AddRoleToEmployee(Role role)
        {
            this.employeeRoles.Add(role);     
        }

        public void RemoveRoleFromEmployee(Role role)
        {
            this.employeeRoles.Remove(role);
        }

        public IEnumerable<Role> GetAllRoles()
        {
            return this.employeeRoles;
        }     
    }
}
